<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 在数组原型上添加 myForEach 方法
      Array.prototype.myForEach = function (callback) {
        for (let i = 0; i < this.length; i++) {
          callback(this[i], i, this)
        }
      }
      let arr = [1, 3, 5, 9]
      const res = arr.myForEach(function (item, index, array) {
        console.log(item)
      })
     
    </script>
  </body>
</html>
